<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="{$_G['addon_url']}/Public/css/weui.css" />
		<link rel="stylesheet" type="text/css" href="{$_G['addon_url']}/Public/css/weui2.css" />
		<link rel="stylesheet" type="text/css" href="{$_G['addon_url']}/Public/css/weui3.css" />
		<link rel="stylesheet" type="text/css" href="{$_G['addon_url']}/Public/css/jquery-weui.min.css" />
		<link rel="stylesheet" type="text/css" href="{$_G['addon_url']}/Public/css/fabu.css" />
		<title></title>

		{:hook('jssdk',false)}
		
	</head>

	<body>
		<div class="weui-header bg-orange">
			<div class="weui-header-left">
				<a class="icon icon-109 f-white">返回</a>
			</div>
			<h1 class="weui-header-title"></h1>

		</div>
		<form action="" method="post">

			<div class="page-bd weui_cell_switch">
				<ul>
						<li class="">
				<div class="weui-flex js-category">
					<p class="weui-flex-item" id="act1">信息分类
						<input name="infoType" id="xinxi2" class="weui_input" value="{$infoType}" type="text" readonly="">
					</p>
					<i class="icon icon-74"></i>
				</div>
				<div class="page-category js-categoryInner">
					<div class="weui_cells weui_cells_access" id="atvanniu" style="margin-top: 0px;">
						<!--<a href="javascript:;" class="weui_btn weui_btn_mini weui_btn_default bg-orange-b">不限</a>-->
						<a href="javascript:;" class="weui_btn weui_btn_mini weui_btn_default">求购信息</a>
						<a href="javascript:;" class="weui_btn weui_btn_mini weui_btn_default">货品信息</a>
					</div>
				</div>
			</li>
					<li class="">
						<div class="weui-flex">
							<p class="weui-flex-item">货品分类 <input class="weui_input" type="text" id="sss" value="" readonly=""></p>
							<i class="icon icon-74"></i>
						</div>
					</li>
				</ul>
			</div>

			<div id="haha">
			<div class="weui_cells weui_cells_form">
				<div class="weui_cell">
		                <div class="weui_cell_hd"><label class="weui_label">店名</label></div>
		                <div class="weui_cell_bd weui_cell_primary">
		                    <input class="weui_input" type="text"  placeholder="请输入店名">
		                </div>
		            </div>
		            <div class="weui_cell">
		                <div class="weui_cell_hd"><label class="weui_label">手机号码</label></div>
		                <div class="weui_cell_bd weui_cell_primary">
		                    <input class="weui_input" type="number" pattern="[0-9]*" placeholder="请输入手机号码">
		                </div>
		            </div>
				</div>
				<div class="weui_cells weui_cells_form">
					
					<div class="weui_cell">
						<div class="weui_cell_bd weui_cell_primary">
							<textarea id="textarea" class="weui_textarea" placeholder="输入描述" rows="3"></textarea>
							<div class="weui_textarea_counter"><span id="count">0</span>/<span id="count_max">500</span></div>
						</div>
					</div>
				</div>
				<div class="weui_cells weui_cells_form">
					<div class="weui_cell">
						<div class="weui_cell_bd weui_cell_primary">
							<div class="weui_uploader">
								<div class="weui_uploader_bd">
									<ul class="weui_uploader_files" id="img2x">

									</ul>
									<div class="weui_uploader_input_wrp">
										<input class="weui_uploader_input" type="button" accept="image/jpg,image/jpeg,image/png,image/gif" onclick="previewImage1(this)" multiple="" />
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<input class="weui_btn weui_btn_warn fabu" type="submit" value="发布" />
		</form>
		</div>
		<script src="{$_G['addon_url']}/Public/js/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="{$_G['addon_url']}/Public/js/jquery-weui.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="{$_G['addon_url']}/Public/js/zepto.min.js" type="text/javascript" charset="utf-8"></script>
		<!--头部分类信息分类-->
		<script type="text/javascript">
			$(function() {
				$('.js-category').click(function(e) {
					$parent = $(this).parent('li');
					if($parent.hasClass('js-show')) {
						$parent.removeClass('js-show');
						$(this).children('i').removeClass('icon-35').addClass('icon-74');
						e.stopPropagation();
					} else {
						$parent.siblings().removeClass('js-show');
						$parent.addClass('js-show');
						$(this).children('i').removeClass('icon-74').addClass('icon-35');
						$parent.siblings().find('i').removeClass('icon-35').addClass('icon-74');
						e.stopPropagation();
					}
				});
				$("#haha").click(function() {
					$nikk = $('.js-category').parent('li');
					$nikk.removeClass('js-show');
					if($nikk.hasClass('js-show')) {
						$('.js-category').children('i').removeClass('icon-35').addClass('icon-74');
					} else {
						$('.js-category').children('i').removeClass('icon-74').addClass('icon-35');
						$nikk.siblings().find('i').removeClass('icon-35').addClass('icon-74');
					}
				});
				$('.weui_cells_access').on('click', 'a', function() {
					$(this).addClass('bg-orange-b').siblings('a').removeClass('bg-orange-b');
					var txt = $(this).text();
					$('#xinxi2').val(txt);
					$('.js-show').removeClass('js-show');
				});


			});
		</script>
<!-- <script type="text/javascript">
			$(function(){
					localIds = "weixin://resourceid/fa1cac4c79781ef5001fa8c8747aece5,weixin://resourceid/c602916a62e7c2f9c0dba5a52c2175a6";
				var imgs    = localIds.split(",");
			        alert("123");
			        alert(imgs[0]);
			})
		</script> -->
		<!--选择图片上传-->
		<script src="{$_G['addon_url']}/Public/js/lrz.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			$imgarr = [];
		</script>
		<script type="text/javascript">
				function imgupload(imgarr){
						var localId = imgarr.pop();
						// var imgs    = localId.split("@%");
						/*判断已经上传了几张图片*/
						if($(".weui_uploader_file").length >= 9){
							$.toast("不准超过9张", "forbidden");
							return false;
						}
						wx.uploadImage({
							localId: localId,
							isShowProgressTips: 1,
							success: function (res) {
								/*直接上传服务器*/
								$.ajax({
									url:"{:create_mobile_url('upload')}",
									type:"post",
									dataType:"json",
									data:{'mediaId':res.serverId.toString()},
									success:function(data){
										$('#img2x').append('<li class="weui_uploader_file weui_uploader_status" style="background-image:url(' + data.path + ')"><div class="weui_uploader_status_content"><i class="icon icon-34"></i></div></li>');
										if(imgarr.length > 0){
										imgupload(imgarr);
										}
											console.log(data);
										},
									error:function(){
										$.toast("错误", "forbidden");
									}
									});
									//其他对serverId做处理的代码
								}
					});
				}
		</script>
		<script type="text/javascript">
			function previewImage1(file) {
				wx.chooseImage({
				    count: 9, // 默认9
				    sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
				    sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
				    success: function (res) {
				        var localIds = res.localIds; // 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片
				        var s = [];
				            s    = localIds.toString().split(",");
				        imgupload(s);
				    }
				});
				// var MAXWIDTH = 100;
				// var MAXHEIGHT = 200;
				// for(var i = 0; i < file.files.length; i++) {

				// 	if(file.files && file.files[i]) {
				// 		var reader = new FileReader();
				// 		reader.onload = function(evt) {
				// 			$('#img2x').append('<li class="weui_uploader_file weui_uploader_status" style="background-image:url(' + evt.target.result + ')"><div class="weui_uploader_status_content"><i class="icon icon-34"></i></div></li>');
				// 		};
				// 		reader.readAsDataURL(file.files[i]);
				// 	}

				// }

			}
		</script>

		<!--计算输入的字符长度-->
		<script type="text/javascript">
			$(function() {
				$('#textarea').bind('input propertychange', function() {
					var cha = $('#textarea').val().length;
					$('#count').text(cha);
				});
				$('#img2x').on('click', '.weui_uploader_status_content', function() {
					$(this).parent('li').remove();
				});
				$('.fabu').on('click',function(){
					alert($('#img2x').children('li').css('background-image'));
//					alert($('#sss').val());
				});
			
			});
			
			


		</script>
		<script src="{$_G['addon_url']}/Public/js/picker.js" type="text/javascript" charset="utf-8"></script>
		<script src="{$_G['addon_url']}/Public/js/picker-city.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			$(function() {
				$("#sss").cityPicker({
					title: "货品分类",
					showDistrict: false
				});
				$("#sss").on('click', function() {
					var html = '<div class="weui_mask weui_actions_mask weui_mask_visible"></div>';
					$('body').append(html);
				});
			});
		</script>
	</body>

</html>